package pos.Configuration;

import java.awt.DisplayMode;
import pos.ICommand;
import pos.Profile;

/**
 *
 * @author plus
 */
public class CommandProfileSet implements ICommand{
    private Profile Receiver;

    public CommandProfileSet(Profile Receiver) {
        this.Receiver = Receiver;
    }
    
    public Object execute(Object Param) {
        String command=(String) Param;
        String [] commandSections=command.split("@");
        String key=commandSections[0], val=commandSections[1];
        System.out.println("Key-"+key+" Value-"+val);
        setProfile(key,val);
        return null;
    }
    private void setProfile(String key, String value){
        if(key.equals("FullScreen")){
            if(value.equals("Enable"))
                Receiver.setFullScreen(true);
            else
                Receiver.setFullScreen(false);
        }else if(key.equals("Res")){
            String []res=value.split("x");
            Receiver.setMode(new DisplayMode(Integer.parseInt(res[0]),
                    Integer.parseInt(res[1]),
                    32,Receiver.getMode().getRefreshRate()));
        }else if(key.equals("DDU")){
            if(value.equals("Enable"))
                Receiver.setDDUScreen(true);
            else
                Receiver.setDDUScreen(false);
        }else if(key.equals("GFX")){
            Receiver.setGFXLevel(Integer.parseInt(value));
        }
    }

}
